name: CascadeStudio - End To End Test

on:
  push:

jobs:
  test:
    name: End to End Test
    runs-on: windows-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2
        with:
          lfs: true

      - name: Cache Node Modules
        uses: actions/cache@v2
        env:
          cache-name: cache-node-modules
        with:
          # npm cache files are stored in `~/.npm` on Linux/macOS
          path: ~/.npm
          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-build-${{ env.cache-name }}-
            ${{ runner.os }}-build-
            ${{ runner.os }}-

      - name: Install Testing Node Modules
        run: |
          cd test
          npm install

      - name: Run Server and Tests
        run: |
          start python "test/server.py"
          cd test
          npx folio --param screenshotOnFailure --param browserName=chromium

      - name: Upload Failing Screenshots
        uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: Screenshots
          path: test/test-results

      - name: Where to go from here
        if: failure()
        run: echo "~~~*** Test failed!  See the README.md in CascadeStudio/test for more information ***~~~"
